home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1997
/
MacHack 1997.toast
/
Hacks
/
Hacks ’94
/
[√] Distribution Restricted!
/
Scott Fought, Chad Walters
/
That Shit's (newer)
/
ThatShits.a
< prev
Wrap
Text File
|
1994-06-25
|
4KB
|
152 lines
; 'That Shits!'
; Copyright 1994, Scott Fought and Chad Walters
;
; Plays sounds as you crash into MacsBug
; Also, keeps AppleTalk connection while you're in MacsBug
;
; Tested with MacsBug 6.5d6 (doesn't work with 6.2.2)
;
; Build in MPW using the following:
; Asm ThatShits.a
; Link ThatShits.a.o -o 'That Shits!' -c 'Sh*t' -t 'INIT' -ra =resSysHeap,resLocked -rt INIT=237
;
; Test App:
; asm TestShit.a
; link TestShit.a.o -o TestShit
;
MACHINE MC68020
INCLUDE 'Traps.a'
INCLUDE 'Sound.a'
INCLUDE 'SysEqu.a'
ResourceStart: MAIN
tst.b MBState
beq.w @Exit
lea (ResourceStart,PC),a0
_RecoverHandle
move.l a0,-(sp)
_DetachResource ; keep this code around (the INIT is locked, system)
bne.s @Exit
move.l TheZone,-(sp) ; save zone
move.l SysZone,TheZone ; switch to System zone
subq.l #2,sp ; result space
pea (mySoundChannel,pc) ; push pointer to the sound channel record
move.w #sampledSynth,-(sp) ; only going to play sampled sounds
move.l #initMono,-(sp) ; mono channel is fine
clr.l -(sp) ; no call back
_SndNewChannel
move.w (sp)+,d0 ; get result
move.l (sp)+,TheZone ; restore zone
tst.w d0 ; test result
bne.s @Exit ; exit if channel init fails
move.l #23701,d6
moveq #5-1,d5
lea (SoundHandleTable,PC),a3
@HandleLoop:
subq.l #4,sp ; return handle space
move.l #'snd ',-(sp)
move.w d6,-(sp)
_Get1Resource
move.l (sp)+,d7 ; did we get it?
beq.s @Exit ; exit if not
move.l d7,-(sp) ; keep the 'snd ' around (its locked, system)
_DetachResource
bne.s @Exit
move.l d7,(a3)+
addq.l #1,d6
dbf d5,@HandleLoop
lea (ReturnAddressTable,PC),a0
moveq #$8,d7
move.l d7,a1
lea (CrashRoutine,PC),a3
moveq #5-1,d7 ; patch 5 vectors starting at 8
@VectorLoop:
move.l (a1),(a0)+ ; store original value in return table
move.l a3,(a1)+ ; replace with our routine
dbf d7,@VectorLoop
move.w #$a08d,d0 ;_DebugUtil
_GetTrapAddress ,newOS
lea (OrigDebugUtil+2,PC),a1
move.l a0,(a1)
move.w #$a08d,d0 ;_DebugUtil
lea (DebugUtil,PC),a0
_SetTrapAddress ,newOS
@Exit:
rts
CrashRoutine:
move.l d0,-(sp)
moveq #0,d0
move.b 4+7(sp),d0 ; get the vector offset from the exception stack frame
subq.w #8,d0 ; table starts with 8
move SR,-(sp)
andi #$0700,(sp)+
bne.s @DontPlay ; if so, don't do the sound
jsr PlayCrashSound
@DontPlay:
move.l (ReturnAddressTable,PC,d0.w),-(sp) ;Get return address
move.l 4(sp),d0 ; restore d0
move.l (sp)+,(sp) ; move address down
rts
PlayCrashSound:
movem.l d0-d2/a0-a1,-(sp)
subq.l #2,sp ; result space
move.l (mySoundChannel,pc),-(sp) ; use our sound channel
move.l (SoundHandleTable,PC,d0.w),-(sp) ; Get sound handle
st -(sp) ; asynchronously
_SndPlay ; OSErr SndPlay(SndChannelPtr chan, Handle sndHdl, Boolean async)
addq.l #2,sp ; pop result, don't care
movem.l (sp)+,d0-d2/a0-a1
rts
DebugUtil:
cmpi.w #3,d0 ; is it DebuggerPoll?
bne.s OrigDebugUtil ; if not, pass through
movem.l d0/d1,-(sp)
move.w $C74,d0 ; get interrupt level when we entered MacsBug
andi.w #$0700,d0
bne.s @Out ; if so, don't lower interrupts
move SR,d0
move d0,d1
andi.w #$F8FF,d1 ; mask off current interrupt level
move d1,SR ; lower interrupt level
nop
move d0,SR ; restore interrupt level
@Out:
movem.l (sp)+,d0/d1
OrigDebugUtil:
jmp $12345678
MySoundChannel: ; stores pointer to sound channel record
DC.L 0
SoundHandleTable: ; table of sounds
DCB.L 5,0
ReturnAddressTable: ; table of original vectors
DCB.L 5,0
END